package com.zhxh.nzpos.setting;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.zhxh.nzpos.R;

/**
 * 登录密码修改界面
 * 
 * @author wangzt
 *
 */
public class PasswordSettingActivity extends Activity {
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting_password);
        initViews();
    }
	
	private void initViews() {
		final EditText oldPwdET = (EditText) findViewById(R.id.old_pwd_et);
		final EditText newPwdET = (EditText) findViewById(R.id.new_pwd_et);
		final EditText newPwdET2 = (EditText) findViewById(R.id.new_pwd_twice_et);
		ImageView okBtn = (ImageView) findViewById(R.id.password_setting_ok_btn);
		okBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// TODO校验并保存密码
				if( oldPwdET.getText().toString().length() == 0 ){
					oldPwdET.setError( "密码不能为空" );
					return;
					
				}
				if( newPwdET.getText().toString().length() == 0 ){
					newPwdET.setError( "密码不能为空" );
					return;
					
				}
				if( newPwdET2.getText().toString().length() == 0 ){
					newPwdET2.setError( "密码不能为空" );
					return;
					
				}
				if(! newPwdET2.getText().toString().equals( newPwdET.getText().toString()) ){
					newPwdET2.setError( "密码不一致" );
					return;
					
				}
				Toast.makeText(getApplicationContext(), "密码修改成功", Toast.LENGTH_SHORT).show();
				finish();
			}
		});
		ImageView cancelBtn = (ImageView) findViewById(R.id.password_setting_cancel_btn);
		cancelBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				finish();
			}
		});
	}
}
